In [23]:
import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.cross_validation import train_test_split
pd.options.mode.chained_assignment = None
from sklearn.externals import joblib
In [34]:
# Read the Titanic_train.csv file here
For this example, we are only extracting 2 things: Class and sex.
Do that below
In [26]:
# Extract the pclass and sex into a new Dataframe
Out[26]:
In [27]:
# Convert pclass to pure numbers
Out[27]:
In [ ]:
# Replace the sex with 0 for female, 1 for male
In [29]:
# Create the expected result dataframe.
In [30]:
# Create test/train split
In [31]:
# Create the random forest instance, and train it with training data
Out[31]:
In [32]:
# Get the accuracy of your model
Out[32]:
In [33]:
# Write the model to a file called "titanic_model2"
Out[33]:
In [ ]: